package com.Ithema.d5_interface;

import java.util.ArrayList;

public class studentoperatorimpl2 implements studentoperator{
    @Override
    public void printallinfo(ArrayList<student> student) {
        System.out.println("---------全部信息---------");
        int count1 =0;
        int count2 =0;
        for (int i = 0; i < student.size(); i++) {
            student s = student.get(i);
            System.out.println("姓名" + s.getName() + "性别" + s.getGender() + "成绩" + s.getScore());
//            System.out.println(student.get(i));
            if(s.getGender()=='女') {
                count1++;
            }
            else{
                count2++;
            }
        }
        System.out.println("男生人数"+count2+"女生人数"+count1);
        System.out.println("全班人数"+student.size());
        System.out.println("----------------------");
    }

    @Override
    public void printaveragescore(ArrayList<student> student) {
        double averagescore = 0;
        double maxscore = student.get(0).getScore();
        double minscore = student.get(0).getScore();
        for (int i = 0; i < student.size(); i++) {
            student s = student.get(i);
            averagescore += s.getScore();
            if(s.getScore()>maxscore) {
                maxscore = s.getScore();
            }
            if(s.getScore()<minscore) {
                minscore = s.getScore();
            }
        }
        System.out.println("最高分"+maxscore);
        System.out.println("最低分"+minscore);
        System.out.println("平均分" + (averagescore-maxscore-minscore) / (student.size()-2));
    }
}
